package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;
import com.sskj.mine.bean.CustomListBean;
import com.sskj.mine.bean.TeamBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.MyTeamActivity;

import java.util.List;

import io.reactivex.Flowable;

public class MyTeamActivityPresenter extends BasePresenter<MyTeamActivity> {
    public void getTitleData() {
        httpService.clientNum()
                .execute(new JsonCallBack<HttpData<TeamBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<TeamBean>> response) {
                        HttpData<TeamBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateTitle(httpData.getData());
                        }
                    }
                });
    }

    public Flowable<List<CustomListBean>> loadData(int page) {
        return httpService.myClient(page)
                .converter(new JsonConverter<HttpData<PageBean<CustomListBean>>>() {
                })
                .adapt(new FlowableBody<>())
                .map(haiPageBeanHttpData -> haiPageBeanHttpData.getData().getList());

    }
}
